#include "cDialogBox.h"
#include <string.h>


cDialogBox::cDialogBox()
{
	displaying = false;
	finish = true;
	delay = 0;
}

cDialogBox::~cDialogBox()
{
}

void cDialogBox::SetPosition(int x, int y){
	this->x = x;
	this->y = y;
}

void  cDialogBox::GetPosition(int *x, int *y){
	*x = this->x;
	*y = this-> y;
}

void cDialogBox::SetMessage(char *msg){
	delay = 0;
	displaying = false;
	finish=false;
	message = msg;
	messageLenght= strlen(message);
	lastCharDisplayed = 0;
}

char* cDialogBox::GetText(){
	return message;
}

void cDialogBox::StartDisplaying(){
	displaying = true;
}



void cDialogBox::Update(){
	if(displaying==true)
	{
		if(delay == 0)
		{
			//Hay que ir incrementando las letras para que se vea el mensaje completo.
			if(messageLenght > lastCharDisplayed)
				lastCharDisplayed++;
		}
		delay= (delay+1) % DIALOG_CHAR_DELAY;
	}
}